# -*- coding: utf-8 -*-
# @Time        :2024/10/11 下午5:23
# @Author      :文刀水寿
# @File        : 05_其他内置方法.py
"""
 @Description :演示Python内置的各类魔术方法
"""


class Student:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    # __str__魔术方法
    def __str__(self):
        return f"我叫{self.name}，我今年{self.age}"

    # __lt__魔术方法
    def __lt__(self, other):
        return self.age < other.age

    # __le__魔术方法
    def __le__(self, other):
        return self.age <= other.age

    # __eq__魔术方法
    def __eq__(self, other):
        return self.age == other.age


stu = Student("周杰伦", 18)
print(stu)

stu = Student("周杰伦", 18)
stu2 = Student("林俊杰", 20)
print(stu < stu2)

stu = Student("周杰伦", 21)
stu2 = Student("林俊杰", 20)
print(stu <= stu2)

stu = Student("周杰伦", 20)
stu2 = Student("林俊杰", 20)
print(stu == stu2)
